/***************************************************************************
 *   Copyright (C) 2006 by Archimedes Projekt   *
 *   thelsb@gmail.com   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef DLGCOMMSETTINGS_H
#define DLGCOMMSETTINGS_H

#include <QWidget>
#include <QString>
#include <ui_commsettings.h>
#include "ui_frmseriallarge.h"
#include "qextserialport.h"
#include "gssglobals.h"

/**
The CamCon port settings widget

     @author Archimedes Projekt <thelsb@gmail.com>
 */
class DlgCommSettings : public QWidget
{
  Q_OBJECT
    public:
        typedef enum  { SMALL, LARGE } uiType;          
  private:
    uiType m_uiType; 
    Ui::CommSettingsWidget ui;
    Ui::FrmSerialLarge uiLarge;
    QextSerialPort *m_serial;
	QString m_port;
	FlowType m_flow;
	BaudRateType m_baud;
	StopBitsType m_stopBits;
	ParityType m_parity;
	DataBitsType m_dataBits;
    MODULE m_module;
    QString m_strPort,
            m_strFlow,
            m_strSpeed,
            m_strStopBits,
            m_strParity,
            m_strDataBits,
            m_strSettings;
    public:
        DlgCommSettings(QString port,QWidget *parent = 0,DlgCommSettings::uiType=SMALL);
        DlgCommSettings(QWidget *parent = 0,DlgCommSettings::uiType=LARGE);
    ~DlgCommSettings();
    void setFlowControl(FlowType flow);
    void setBaudRate(BaudRateType baud);
    void setStopBits(StopBitsType stopBits);
    void setParity(ParityType parity);
    void setDataBits(DataBitsType dataBits);
    void setPort(const QString &port);
    QextSerialPort * serial();
    const QString & settingsStr() const;
    const QString & portStr() const;
    const QString & stopBitsStr() const;
    const QString & parityStr() const;
    const QString & flowStr() const;
    const QString & dataBitsStr() const;
    const QString & speedStr() const;
    void setSettingsStr(const QString &settings);
    void setDataBitsStr(const QString &dataBits);
    void setFlowStr(const QString &flow);
    void setParityStr(const QString &parity);
    void setPortStr(const QString &port);
    void setSpeedStr(const QString &speed);
    void setStopBitsStr(const QString &stopBits);

public slots:
    void initSerial();
    void connectSerial();
    void saveConfig();
    void loadConfig(MODULE module);
    void loadConfig();
    void updateSettigsLable();
signals:
    void sig_serialSettings();
    void sig_hide();
};

#endif
